package com.lagou.edu.minicat;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * 封装Request和Response对象，返回html静态资源文件
 *
 * @author gaoguangyang
 */
public class BootstrapV2 {

    private int port = 8080;

    public void startV2() throws IOException {
        ServerSocket serverSocket = new ServerSocket(port);
        while (true) {
            Socket accept = serverSocket.accept();
            Request request = new Request(accept.getInputStream());
            Response response = new Response(accept.getOutputStream());
            response.outputHtml(request.getUrl());
            accept.close();
        }
    }

    public static void main(String[] args) throws IOException {
        BootstrapV2 bootstrapV2 = new BootstrapV2();
        bootstrapV2.startV2();
    }
}
